# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=x264

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=r2409.d6b4e63
pkgrel=1
pkgdesc="Library for encoding H264/AVC video streams (mingw-w64)"
arch=('any')
url="http://www.videolan.org/developers/x264.html"
license=("custom")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "yasm")
depends=("${MINGW_PACKAGE_PREFIX}-libwinpthread")
options=('strip' 'staticlibs')
source=("$_realname"::"git://git.videolan.org/x264.git")
md5sums=('SKIP')

pkgver() {
  cd ${srcdir}/${_realname}
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
}
